package com.zzsy.carosshopprojects.activitys.home.mainpage.charge;

import android.content.Context;

import com.king.base.util.ToastUtils;
import com.zzsy.carosshopprojects.base.BaseViewMode;
import com.zzsy.carosshopprojects.bean.GetOilsListBean;
import com.zzsy.carosshopprojects.network.RequestUtils;
import com.zzsy.carosshopprojects.network.Utils.MyObserver;
import com.zzsy.carosshopprojects.util.DataUtil;

import java.util.List;

import androidx.lifecycle.MutableLiveData;

public class ChoseOilMode extends BaseViewMode {
    private MutableLiveData<List<GetOilsListBean>> liveData;

    public MutableLiveData<List<GetOilsListBean>> getLiveData() {
        if (liveData == null)
            liveData = new MutableLiveData<>();
        return liveData;
    }

    public void getData(Context context) {
        RequestUtils.OilListByStoreId(context, DataUtil.getInstance().getStoreId(), new MyObserver<List<GetOilsListBean>>(context) {
            @Override
            public void onSuccess(List<GetOilsListBean> result) {
                liveData.postValue(result);
            }

            @Override
            public void onFailure(Throwable e, String errorMsg, int code) {
                ToastUtils.showToast(context.getApplicationContext(), errorMsg);
            }
        });
    }
}
